package com.wngbms.aop._03;

import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

import java.lang.annotation.Annotation;

@Aspect
public class AspectAnnotationConfig2 implements Ordered {

    @Pointcut("execution(public * *(..))")
    private void anyPublicMethod() {
    }

    @Before("anyPublicMethod()")
    public void beforeAnyPublicMethod() {
        System.out.println("before any public... 2");
    }

    /**
     * before any public... 2
     * around any method
     * before any public...
     *
     * @return
     */
    @Override
    public int getOrder() {
        // No MethodInvocation found:
        // Check that an AOP invocation is in progress
        // and that the ExposeInvocationInterceptor is upfront in the interceptor chain.
        // Specifically, note that advices with order HIGHEST_PRECEDENCE will
        // execute before ExposeInvocationInterceptor!
        // In addition, ExposeInvocationInterceptor
        // and ExposeInvocationInterceptor.currentInvocation()
        // must be invoked from the same thread.
//        return HIGHEST_PRECEDENCE;

        return 20;
    }
}
